package com.example.shiro_realy.dao;

import com.example.shiro_realy.domian.Role;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

public interface RoleMapper {
    @Select("SELECT " +
            "ur.role_id as id ,r.name as name ,r.description as description " +
            "from user_role ur " +
            "LEFT JOIN role r ON ur.role_id = r.id " +
            "WHERE ur.user_id=#{userId}")
    @Results(value = {
            @Result(id = true,property = "id",column = "id"),
            @Result(property = "name",column = "name"),
            @Result(property = "description",column = "description"),
            @Result(property = "permissionList",column = "id",
            many = @Many(select =
                    "com.example.shiro_realy.dao.PermissionMapper.findPermissionByRoleId"//直接引用这个查询语句
                    ,fetchType = FetchType.DEFAULT))})
    List<Role> findRoleByUserId(@Param("userId")int userId);








}
